﻿####################################################################################
# Court Whores - In Semen Patch: application + one-shot legacy cleanup.
####################################################################################

namespace = cw_insemen

# Fired via carn_on_sex_v2 after every sex resolution. Rolls the overlay
# flags for every participant with the court_whore trait.
cw_insemen.0002 = {
    type = character_event
    hidden = yes
    immediate = {
        scope:carn_sex_player ?= {
            if = {
                limit = { has_trait = court_whore }
                cw_insemen_apply_effect = yes
            }
        }
        scope:carn_sex_partner ?= {
            if = {
                limit = { has_trait = court_whore }
                cw_insemen_apply_effect = yes
            }
        }
    }
}

# One-shot legacy cleanup for saves played under v1-v3 of this patch, which
# handed out CBO's cum_* traits directly. Strips them from everyone once, then
# never runs again. Also covers traits stranded by aborted CBO scene chains.
cw_insemen.0003 = {
    # scope = none: yearly_global_pulse has no scopes attached (see
    # game/common/on_action/_on_actions.info), so this must not be a
    # character_event. every_living_character is a global list and works here.
    scope = none
    hidden = yes
    trigger = {
        NOT = { has_global_variable = cw_insemen_legacy_cleaned }
    }
    immediate = {
        set_global_variable = cw_insemen_legacy_cleaned
        every_living_character = {
            limit = {
                OR = {
                    has_trait = cum_doggy_1
                    has_trait = cum_doggy_2
                    has_trait = cum_doggy_3
                    has_trait = cum_miss_1
                    has_trait = cum_miss_2
                    has_trait = cum_miss_3
                    has_trait = cum_oral_1
                    has_trait = cum_oral_2
                    has_trait = cum_oral_3
                }
            }
            cw_insemen_clear_effect = yes
        }
    }
}